package com.tiancheng.trade.settlement.vo.settlement.export;

import com.tiancheng.trade.settlement.enums.CheckSummaryCheckResultEnum;
import com.tiancheng.trade.settlement.model.settlement.SettleSummary;
import com.tiancheng.trade.settlement.util.AmountUtil;
import com.tiancheng.trade.settlement.util.ObjectConvertUtil;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

import java.math.BigDecimal;
import java.time.LocalDate;

@Getter
@Setter
@ToString
public class SettleByMerchantExportVo {
    /**
     * 实际清算日期
     *
     * @mbg.generated 2021-03-26 14:29:49
     */
    private LocalDate actualClearDate;

    /**
     * 交易渠道
     *
     * @mbg.generated 2021-03-26 14:29:49
     */
    private String payChannel;
    /**
     * 机构名称
     */
    private String organizationName;
    /**
     * 商户名称（中台）
     *
     * @mbg.generated 2021-03-26 14:29:49
     */
    private String merchantName;
    /**
     * 结算类型
     */
    private String settleRuleName;
    /**
     * 业务场景
     */
    private String sourcesName;
    /**
     * 中台交易金额总和（分）
     *
     * @mbg.generated 2021-03-26 14:29:49
     */
    private BigDecimal mdFlowTotalAmountBD;
    /**
     * 渠道交易金额总和（分）
     *
     * @mbg.generated 2021-03-26 14:29:49
     */
    private BigDecimal channelFlowTotalAmountBD;

    /**
     * 交易差异金额（分）
     *
     * @mbg.generated 2021-03-26 14:29:49
     */
    private BigDecimal differentAmountFlowBD;


    /**
     * 中台退款金额总和（分）
     *
     * @mbg.generated 2021-03-26 14:29:49
     */
    private BigDecimal mdRefundTotalAmountBD;
    /**
     * 渠道退款金额总和（分）
     *
     * @mbg.generated 2021-03-26 14:29:49
     */
    private BigDecimal channelRefundTotalAmountBD;
    /**
     * 退款差异金额（分）
     *
     * @mbg.generated 2021-03-26 14:29:49
     */
    private BigDecimal differentAmountRefundBD;

    /**
     * 中台清出金额总和（分）
     *
     * @mbg.generated 2021-03-26 14:29:49
     */
    private BigDecimal mdClearTotalAmountBD;
    /**
     * 渠道清出金额总和（分）
     *
     * @mbg.generated 2021-03-26 14:29:49
     */
    private BigDecimal channelClearTotalAmountBD;
    /**
     * 清出差异金额（分）
     *
     * @mbg.generated 2021-03-26 14:29:49
     */
    private BigDecimal differentAmountClearBD;

    /**
     * 平台抽佣金额（分）
     *
     * @date 2021-06-23
     */
    private BigDecimal distAmountBD;


    /**
     * 对账结果：0=异常；1=正常；
     *
     * @mbg.generated 2021-03-26 14:29:49
     */
    private String checkResultStr;

    public static SettleByMerchantExportVo build(SettleSummary s){
        SettleByMerchantExportVo entity = ObjectConvertUtil.convert(s, SettleByMerchantExportVo.class).get();
        entity.setMdFlowTotalAmountBD(AmountUtil.getYUAN(Math.toIntExact(s.getMdFlowTotalAmount())));
        entity.setChannelFlowTotalAmountBD(AmountUtil.getYUAN(Math.toIntExact(s.getChannelFlowTotalAmount())));
        entity.setDifferentAmountFlowBD(AmountUtil.getYUAN(Math.toIntExact(s.getDifferentAmountFlow())));
        entity.setMdRefundTotalAmountBD(AmountUtil.getYUAN(Math.toIntExact(s.getMdRefundTotalAmount())));
        entity.setChannelRefundTotalAmountBD(AmountUtil.getYUAN(Math.toIntExact(s.getChannelRefundTotalAmount())));
        entity.setDifferentAmountRefundBD(AmountUtil.getYUAN(Math.toIntExact(s.getDifferentAmountRefund())));
        entity.setMdClearTotalAmountBD(AmountUtil.getYUAN(Math.toIntExact(s.getMdClearTotalAmount())));
        entity.setChannelClearTotalAmountBD(AmountUtil.getYUAN(Math.toIntExact(s.getChannelClearTotalAmount())));
        entity.setDifferentAmountClearBD(AmountUtil.getYUAN(Math.toIntExact(s.getDifferentAmountClear())));
        entity.setCheckResultStr(CheckSummaryCheckResultEnum.getDesc(s.getCheckResult()));

        entity.setDistAmountBD(AmountUtil.getYUAN(Math.toIntExact(s.getDistAmount())));
        return entity;
    }
}
